<?php require admin_tpl('header')?>

<div class="tab">
	<ul>
		<?php if ( check_perm('blog','post') ) { ?>
		<li><a href="?mod=blog&ac=write">撰写文章</a></li>
		<?php } ?>
		<li><a href="?mod=blog&ac=list" class="on">文章列表</a></li>
		<?php if ( check_perm('blog','addcate') ||  check_perm('blog','editcate') ||  check_perm('blog','delcate')) { ?>
		<li><a href="?mod=blog&ac=category">文章分类</a></li>
		<?php } ?>
		<?php if ( is_founder() ) { ?>
		<li><a href="?mod=blog&ac=blogmeta">自定义域</a></li>
		<?php }?>
	</ul>
</div>

	<div class="main">

		<div class="search">
			<form name="search" method="get" action="admin.php">
			<input type="hidden" name="mod" value="blog" />
			<input type="hidden" name="ac" value="list" />
				<fieldset>
					<legend>日志查找</legend>
						分类：
						<select name="cateid">
							<option value="">所有分类</option>
							<?php echo cate_options('blog', $cateid)?>
						</select>
						状态：
						<select name="status">
							<option value="">任意</option>
							<option value="-1">草稿</option>
							<option value="0">未审核</option>
							<option value="1">已审核</option>
						</select>
						关键字：
						<input type="text" name="keyword" size="15" value="<?php echo $keyword?>" />
						<input type="submit" name="s" class="button" value="开始查找" />
						<input type="button" class="button" value="所有文章" onclick="javascript:window.location.href='?mod=blog';" />
				</fieldset>
			</form>
		</div>

		<form name="op" method="post" action="?mod=blog">
		<table cellspacing="0" class="datalist" id="list">
			<tr>
				<th width="30" class="firstcol">选择</th>
				<th width="50">
				<?php
				if ( $order == 'id' && $ascdesc == 'asc' ) {
					echo '<a href="'.$url.'&order=id&ascdesc=desc" title="按ID从大到小排序">ID↑</a>';
				} else {
					echo '<a href="'.$url.'&order=id&ascdesc=asc" title="按ID从小到大排序">ID↓</a>';
				}
				?>
				</th>
				<th width="*">标题</th>
				<th width="80">作者</th>
				<th width="120">分类</th>
				<th width="60">
				<?php
				if ( $order == 'views' && $ascdesc == 'desc' ) {
					echo '<a href="'.$url.'&order=views&ascdesc=asc" title="按阅读次数从少到多排序">阅读↓</a>';
				} else {
					echo '<a href="'.$url.'&order=views&ascdesc=desc" title="按阅读次数从多到少排序">阅读↑</a>';
				}
				?>
				</th>
				<th width="60">
				<?php
				if ( $order == 'comments' && $ascdesc == 'desc' ) {
					echo '<a href="'.$url.'&order=comments&ascdesc=asc" title="按评论次数从少到多排序">评论↓</a>';
				} else {
					echo '<a href="'.$url.'&order=comments&ascdesc=desc" title="按评论次数从多到少排序">评论↑</a>';
				}
				?>
				</th>
				<th width="150">时间</th>
			</tr>
		<?php
		if ( $result ) :
			foreach ($result as $row) : ?>
			<tr id="row_<?php echo $row['id']?>"  <?php echo $row['status']==0 ? 'class="highlight"' : '';?>>
				<td align="center">
				<input type="checkbox" name="id[]" value="<?php echo $row['id']?>" class="checkbox" />
				</td>
				<td align="center"><?php echo $row['id']?></td>
				<td><a href="?mod=blog&ac=write&id=<?php echo $row['id']?>" title="编辑这篇文章"><?php echo cut_str($row['title'],50)?></a>
				<?php
				switch ($row['status']) {
					case 0 :
						echo '<span style="color:red">[未审核]</span>';break;
					case -1 :
						echo '<span style="color:red">[草稿]</span>';break;;
				}
				if (!empty($row['password'])) {
					echo '<img src="admin/images/lock.gif" alt="密码访问" />';
				}
				?>
				</td>
				<td align="center"><a href="<?php echo $url.'&userid='.$row['userid']?>" title="只看该作者"><?php echo $row['username']?></a></td>
				<td align="center"><a href="<?php echo $url.'&cateid='.$row['cateid']?>" title="只看该分类"><?php echo $row['catename']?></a></td>
				<td align="center"><b style="color:red"><?php echo $row['views']?></b></td>
				<td align="center"><a href="?mod=comment&postid=<?php echo $row['id']?>" title="查看该文章下的评论"><b style="color:green"><?php echo $row['comments']?></b></a></td>
				<td align="center"><?php echo get_date($row['dateline'],'Y年m月d日')?></td>
			</tr>
			<?php endforeach; ?>
			<tr>
				<td align="center">
				<input type="checkbox" name="chkall2" value="1" class="checkbox" onclick="check_all(this)" /></td>
				<td align="center"><label for="chkall">全选</label></td>
				<td colspan="6">
				<?php if ( check_perm('blog','del') ) { ?>
				<input type="radio" name="ac" id="delete" value="delete" class="radio" /><label for="delete">删除</label>
				<?php } ?>
				<?php if ( check_perm('blog','check') ) { ?>
				<input type="radio" name="ac"  id="upstat" value="upstat" class="radio" /><label for="upstat">状态</label>
				<select name="status" onfocus="$('#upstat').attr('checked','checked')">
					<option value="1">已审核</option>
					<option value="0">未审核</option>
					<option value="-1">草稿</option>
				</select>
				<?php } ?>
				<?php if ( check_perm('blog','move') ) { ?>
				<input type="radio" name="ac" value="move" id="move" class="radio" /><label for="move">移动到</label>
				<select name="cateid" onfocus="$('#move').attr('checked','checked')">
					<option value="">请选择</option>
					<?php echo cate_options('blog')?>
				</select>
				<?php } ?>
				<input type="submit" class="submit" value="执行操作" /></td>
			</tr>
			<?php else : ?>
			<tr><td colspan="10">没有符合条件的文章</td></tr>
			<?php endif; ?>
			<tr>
				<td colspan="10"><?php echo multipage()?></td>
			</tr>
		</table>
		</form>

	</div>

<?php require admin_tpl('footer')?>